﻿using Mimi.Models.DataModels;
using Mimi.ViewModels;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mimi.Models.UIModels
{
    public class UIPurpose : BindingBase
    {
        #region Properties
        /// <summary>
        /// Purpose Id to help synchronize between UI item and logical item
        /// </summary>
        public string PurposeId { get; set; }

        private string description;
        /// <summary>
        /// Description
        /// </summary>
        public string Description
        {
            get { return description; }
            set
            {
                Set(ref description, value);
            }
        }

        private string budget;
        /// <summary>
        /// Budget
        /// </summary>
        public string Budget
        {
            get { return budget; }
            set
            {
                Set(ref budget, value);
            }
        }

        private string quota;
        /// <summary>
        /// Quota
        /// </summary>
        public string Quota
        {
            get { return quota; }
            set
            {
                Set(ref quota, value);
            }
        }

        private Currency currency;
        /// <summary>
        /// Currency
        /// </summary>
        public Currency Currency
        {
            get 
            {
                return currency; 
            }
            set
            {
                Set(ref currency, value);
            }
        }

        private string type;
        /// <summary>
        /// Value Type
        /// </summary>
        public string Type
        {
            get { return type; }
            set 
            {
                Set(ref type, value);
            }
        }
        #endregion

        /// <summary>
        /// Default constructor
        /// </summary>
        public UIPurpose()
        {

        }

        /// <summary>
        /// parameter constructor
        /// </summary>
        /// <param name="purpose"></param>
        public UIPurpose(Purpose purpose)
        {
            this.PurposeId = purpose.PurposeId;
            this.Description = purpose.Description;
            this.Quota = purpose.Quota.ToString();
            this.Budget = purpose.Budget.ToString();
            this.Currency = purpose.Currency;
            this.Type = purpose.Type == PurposeUnitValueType.Percentage ? "%" : (Currency == Currency.USD) ? "$" : "K"; 
        }
    }
}
